home *** CD-ROM | disk | FTP | other *** search
/ Aminet 21 / Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso / Aminet / gfx / show / gs_src_gs.lha / gs5.03 / gxdevice.h < prev    next >
C/C++ Source or Header  |  1997-07-25  |  40KB  |  992 lines

  1. /* Copyright (C) 1989, 1996, 1997 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of Aladdin Ghostscript.
  4.   
  5.   Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author
  6.   or distributor accepts any responsibility for the consequences of using it,
  7.   or for whether it serves any particular purpose or works at all, unless he
  8.   or she says so in writing.  Refer to the Aladdin Ghostscript Free Public
  9.   License (the "License") for full details.
  10.   
  11.   Every copy of Aladdin Ghostscript must include a copy of the License,
  12.   normally in a plain ASCII text file named PUBLIC.  The License grants you
  13.   the right to copy, modify and redistribute Aladdin Ghostscript, but only
  14.   under certain conditions described in the License.  Among other things, the
  15.   License requires that the copyright notice and this notice be preserved on
  16.   all copies.
  17. */
  18.  
  19. /* gxdevice.h */
  20. /* Device description structure */
  21.  
  22. #ifndef gxdevice_INCLUDED
  23. #  define gxdevice_INCLUDED
  24.  
  25. #include "stdio_.h"        /* for FILE */
  26. #include "gsdcolor.h"
  27. #include "gsmatrix.h"
  28. #include "gsiparam.h"        /* requires gsmatrix.h */
  29. #include "gsropt.h"
  30. #include "gsstruct.h"
  31. #include "gsxfont.h"
  32. #include "gxbitmap.h"
  33. #include "gxcindex.h"
  34. #include "gxcvalue.h"
  35. #include "gxfixed.h"
  36.  
  37. /* See drivers.doc for documentation of the driver interface. */
  38.  
  39. #ifndef gx_device_DEFINED
  40. #  define gx_device_DEFINED
  41. typedef struct gx_device_s gx_device;
  42. #endif
  43.  
  44. /* We need at least an abstract type for a graphics state, */
  45. /* which is passed to the page device procedures. */
  46. #ifndef gs_state_DEFINED
  47. #  define gs_state_DEFINED
  48. typedef struct gs_state_s gs_state;
  49. #endif
  50.  
  51. /* We need abstract types for paths and fill/stroke parameters, */
  52. /* for the path-oriented device procedures. */
  53. #ifndef gx_path_DEFINED
  54. #  define gx_path_DEFINED
  55. typedef struct gx_path_s gx_path;
  56. #endif
  57. #ifndef gx_clip_path_DEFINED
  58. #  define gx_clip_path_DEFINED
  59. typedef struct gx_clip_path_s gx_clip_path;
  60. #endif
  61. #ifndef gx_fill_params_DEFINED
  62. #  define gx_fill_params_DEFINED
  63. typedef struct gx_fill_params_s gx_fill_params;
  64. #endif
  65. #ifndef gx_stroke_params_DEFINED
  66. #  define gx_stroke_params_DEFINED
  67. typedef struct gx_stroke_params_s gx_stroke_params;
  68. #endif
  69. #ifndef gs_imager_state_DEFINED
  70. #  define gs_imager_state_DEFINED
  71. typedef struct gs_imager_state_s gs_imager_state;
  72. #endif
  73.  
  74. /* Define the type for colors passed to the higher-level procedures. */
  75. typedef gx_device_color gx_drawing_color;
  76.  
  77. /* Define a type for telling get_alpha_bits what kind of object */
  78. /* is being rendered. */
  79. typedef enum {
  80.     go_text,
  81.     go_graphics
  82. } graphics_object_type;
  83.  
  84. /* Define an edge of a trapezoid.  Requirement: end.y >= start.y. */
  85. typedef struct gs_fixed_edge_s {
  86.     gs_fixed_point start;
  87.     gs_fixed_point end;
  88. } gs_fixed_edge;
  89.  
  90. /* Define the structure for device color capabilities. */
  91. typedef struct gx_device_color_info_s {
  92.     int num_components;        /* 1 = gray only, 3 = RGB, */
  93.                     /* 4 = CMYK */
  94.     int depth;            /* # of bits per pixel */
  95.     gx_color_value max_gray;    /* # of distinct gray levels -1 */
  96.     gx_color_value max_color;    /* # of distinct color levels -1 */
  97.                     /* (only relevant if num_comp. > 1) */
  98.     gx_color_value dither_grays;    /* size of gray ramp for dithering */
  99.     gx_color_value dither_colors;    /* size of color cube ditto */
  100.                     /* (only relevant if num_comp. > 1) */
  101. } gx_device_color_info;
  102. #define dci_values(nc,depth,mg,mc,dg,dc) { nc, depth, mg, mc, dg, dc }
  103. #define dci_std_color(color_bits)\
  104.   dci_values(\
  105.     (color_bits == 32 ? 4 : color_bits > 1 ? 3 : 1),\
  106.     ((color_bits > 1) & (color_bits < 8) ? 8 : color_bits),\
  107.     (color_bits >= 8 ? 255 : 1),\
  108.     (color_bits >= 8 ? 255 : color_bits > 1 ? 1 : 0),\
  109.     (color_bits >= 8 ? 5 : 2),\
  110.     (color_bits >= 8 ? 5 : color_bits > 1 ? 2 : 0)\
  111.   )
  112. #define dci_black_and_white dci_std_color(1)
  113. #define dci_black_and_white_() dci_black_and_white
  114. #define dci_color(depth,maxv,dither)\
  115.   dci_values(3, depth, maxv, maxv, dither, dither)
  116. #define gx_device_has_color(dev) ((dev)->color_info.num_components > 1)
  117.  
  118. /* Structure for device procedures. */
  119. typedef struct gx_device_procs_s gx_device_procs;
  120.  
  121. /* Structure for page device procedures. */
  122. /* Note that these take the graphics state as a parameter. */
  123. typedef struct gx_page_device_procs_s {
  124.  
  125. #define dev_page_proc_install(proc)\
  126.   int proc(P2(gx_device *dev, gs_state *pgs))
  127.     dev_page_proc_install((*install));
  128.  
  129. #define dev_page_proc_begin_page(proc)\
  130.   int proc(P2(gx_device *dev, gs_state *pgs))
  131.     dev_page_proc_begin_page((*begin_page));
  132.  
  133. #define dev_page_proc_end_page(proc)\
  134.   int proc(P3(gx_device *dev, int reason, gs_state *pgs))
  135.     dev_page_proc_end_page((*end_page));
  136.  
  137. } gx_page_device_procs;
  138. /* Default procedures */
  139. dev_page_proc_install(gx_default_install);
  140. dev_page_proc_begin_page(gx_default_begin_page);
  141. dev_page_proc_end_page(gx_default_end_page);
  142.  
  143. /* Define default pages sizes. */
  144. /* U.S. letter paper (8.5" x 11"). */
  145. #define DEFAULT_WIDTH_10THS_US_LETTER 85
  146. #define DEFAULT_HEIGHT_10THS_US_LETTER 110
  147. /* A4 paper (210mm x 297mm).  The dimensions are off by a few mm.... */
  148. #define DEFAULT_WIDTH_10THS_A4 83
  149. #define DEFAULT_HEIGHT_10THS_A4 117
  150. /* Choose a default.  A4 may be set in the makefile. */
  151. #ifdef A4
  152. #  define DEFAULT_WIDTH_10THS DEFAULT_WIDTH_10THS_A4
  153. #  define DEFAULT_HEIGHT_10THS DEFAULT_HEIGHT_10THS_A4
  154. #else
  155. #  define DEFAULT_WIDTH_10THS DEFAULT_WIDTH_10THS_US_LETTER
  156. #  define DEFAULT_HEIGHT_10THS DEFAULT_HEIGHT_10THS_US_LETTER
  157. #endif
  158.  
  159. /* ---------------- Device structure ---------------- */
  160.  
  161. /*
  162.  * Define the generic device structure.  The device procedures can
  163.  * have two different configurations:
  164.  * 
  165.  *    - Statically initialized devices predating release 2.8.1
  166.  *    set the static_procs pointer to point to a separate procedure record,
  167.  *    and do not initialize std_procs.
  168.  *
  169.  *    - Statically initialized devices starting with release 2.8.1,
  170.  *    and all dynamically created device instances,
  171.  *    set the static_procs pointer to 0, and initialize std_procs.
  172.  *
  173.  * The gx_device_set_procs procedure converts the first of these to
  174.  * the second, which is what all client code starting in 2.8.1 expects
  175.  * (using the std_procs record, not the static_procs pointer, to call the
  176.  * driver procedures).
  177.  *
  178.  * The choice of the name Margins (rather than, say, HWOffset), and the
  179.  * specification in terms of a default device resolution rather than
  180.  * 1/72" units, are due to Adobe.
  181.  *
  182.  * ****** NOTE: If you define any subclasses of gx_device, you *must* define
  183.  * ****** the finalization procedure as gx_device_finalize.  Finalization
  184.  * ****** procedures are not automatically inherited.
  185.  */
  186. #define gx_device_common\
  187.     int params_size;        /* OBSOLETE if stype != 0: */\
  188.                     /* size of this structure */\
  189.     const gx_device_procs *static_procs;    /* OBSOLETE */\
  190.                     /* pointer to std_procs */\
  191.     const char *dname;        /* the device name */\
  192.     gs_memory_t *memory;        /* (0 iff static prototype) */\
  193.     gs_memory_type_ptr_t stype;    /* memory manager structure type, */\
  194.                     /* 0 iff static prototype */\
  195.     bool is_open;            /* true if device has been opened */\
  196.     int max_fill_band;        /* limit on band size for fill, */\
  197.                     /* must be 0 or a power of 2 */\
  198.                     /* (see gdevabuf.c for more info) */\
  199.     gx_device_color_info color_info;    /* color information */\
  200.     int width;            /* width in pixels */\
  201.     int height;            /* height in pixels */\
  202.     float MediaSize[2];        /* media dimensions in points */\
  203.     float ImagingBBox[4];        /* imageable region in points */\
  204.       bool ImagingBBox_set;\
  205.     float HWResolution[2];        /* resolution, dots per inch */\
  206.     float MarginsHWResolution[2];    /* resolution for Margins */\
  207.     float Margins[2];        /* offset of physical page corner */\
  208.                     /* from device coordinate (0,0), */\
  209.                     /* in units given by MarginsHWResolution */\
  210.     float HWMargins[4];        /* margins around imageable area, */\
  211.                     /* in default user units ("points") */\
  212.     long PageCount;            /* number of pages written */\
  213.     long ShowpageCount;        /* number of calls on showpage */\
  214.     bool IgnoreNumCopies;        /* if true, force num_copies = 1 */\
  215.     gx_page_device_procs page_procs;    /* must be last */\
  216.         /* end of std_device_body */\
  217.     gx_device_procs std_procs    /* standard procedures */
  218. #define x_pixels_per_inch HWResolution[0]
  219. #define y_pixels_per_inch HWResolution[1]
  220. #define offset_margin_values(x, y, left, bot, right, top)\
  221.   {x, y}, {left, bot, right, top}
  222. #define margin_values(left, bot, right, top)\
  223.   offset_margin_values(0, 0, left, bot, right, top)
  224. #define no_margins margin_values(0, 0, 0, 0)
  225. #define no_margins_() no_margins
  226. /* Define macros that give the page offset ("Margins") in inches. */
  227. #define dev_x_offset(dev) ((dev)->Margins[0] / (dev)->MarginsHWResolution[0])
  228. #define dev_y_offset(dev) ((dev)->Margins[1] / (dev)->MarginsHWResolution[1])
  229. #define dev_y_offset_points(dev) (dev_y_offset(dev) * 72.0)
  230. /* Note that left/right/top/bottom are defined relative to */
  231. /* the physical paper, not the coordinate system. */
  232. /* For backward compatibility, we define macros that give */
  233. /* the margins in inches. */
  234. #define dev_l_margin(dev) ((dev)->HWMargins[0] / 72.0)
  235. #define dev_b_margin(dev) ((dev)->HWMargins[1] / 72.0)
  236. #define dev_b_margin_points(dev) ((dev)->HWMargins[1])
  237. #define dev_r_margin(dev) ((dev)->HWMargins[2] / 72.0)
  238. #define dev_t_margin(dev) ((dev)->HWMargins[3] / 72.0)
  239. #define dev_t_margin_points(dev) ((dev)->HWMargins[3])
  240. /* The extra () are to prevent premature expansion. */
  241. #define open_init_closed() 0 /*false*/, 0 /* max_fill_band */
  242. #define open_init_open() 1 /*true*/, 0 /* max_fill_band */
  243. /* Accessors for device procedures */
  244. #define dev_proc(dev, p) ((dev)->std_procs.p)
  245. #define set_dev_proc(dev, p, proc) ((dev)->std_procs.p = (proc))
  246. #define fill_dev_proc(dev, p, dproc)\
  247.   if ( dev_proc(dev, p) == 0 ) set_dev_proc(dev, p, dproc)
  248.  
  249. /*
  250.  * To insulate statically defined device templates from the
  251.  * consequences of changes in the device structure, the following macros
  252.  * must be used for generating initialized device structures.
  253.  *
  254.  * The computations of page width and height in pixels should really be
  255.  *    ((int)(page_width_inches*x_dpi))
  256.  * but some compilers (the Ultrix 3.X pcc compiler and the HPUX compiler)
  257.  * can't cast a computed float to an int.  That's why we specify
  258.  * the page width and height in inches/10 instead of inches.
  259.  *
  260.  * Note that the macro is broken up so as to be usable for devices that
  261.  * add further initialized state to the generic device.
  262.  * Note also that the macro does not initialize std_procs, which is
  263.  * the next element of the structure.
  264.  */
  265. #define std_device_part1_(devtype, ptr_procs, dev_name, stype, open_init)\
  266.     sizeof(devtype), ptr_procs, dev_name,\
  267.     0 /*memory*/, stype, open_init() /*stype, is_open, cached*/
  268. /* color_info goes here */
  269. /*
  270.  * The MetroWerks compiler has some bizarre bug that produces a spurious
  271.  * error message if the width and/or height are defined as 0 below,
  272.  * unless we use the +/- workaround in the next macro.
  273.  */
  274. #define std_device_part2_(width, height, x_dpi, y_dpi)\
  275.     width, height,\
  276.     { (((width) * 72.0 + 0.5) - 0.5) / (x_dpi),\
  277.       (((height) * 72.0 + 0.5) - 0.5) / (y_dpi) },\
  278.     { 0, 0, 0, 0 }, 0/*false*/, { x_dpi, y_dpi }, { x_dpi, y_dpi }
  279. /* offsets and margins go here */
  280. #define std_device_part3_()\
  281.     0, 0, 0/*false*/,\
  282.     { gx_default_install, gx_default_begin_page, gx_default_end_page }
  283. /*
  284.  * We need a number of different variants of the std_device_ macro simply
  285.  * because we can't pass the color_info or offsets/margins
  286.  * as macro arguments, which in turn is because of the early macro
  287.  * expansion issue noted in stdpre.h.  The basic variants are:
  288.  *    ...body_with_macros_, which uses 0-argument macros to supply
  289.  *      open_init, color_info, and offsets/margins;
  290.  *    ...full_body, which takes 12 values (6 for dci_values,
  291.  *      6 for offsets/margins);
  292.  *    ...color_full_body, which takes 9 values (3 for dci_color,
  293.  *      6 for margins/offset).
  294.  *    ...std_color_full_body, which takes 7 values (1 for dci_std_color,
  295.  *      6 for margins/offset).
  296.  *    
  297.  */ 
  298. #define std_device_body_with_macros_(dtype, pprocs, dname, stype, w, h, xdpi, ydpi, open_init, dci_macro, margins_macro)\
  299.     std_device_part1_(dtype, pprocs, dname, stype, open_init),\
  300.     dci_macro(),\
  301.     std_device_part2_(w, h, xdpi, ydpi),\
  302.     margins_macro(),\
  303.     std_device_part3_()
  304.  
  305. #define std_device_std_body(dtype, pprocs, dname, w, h, xdpi, ydpi)\
  306.     std_device_body_with_macros_(dtype, pprocs, dname, 0,\
  307.       w, h, xdpi, ydpi,\
  308.       open_init_closed, dci_black_and_white_, no_margins_)
  309.  
  310. #define std_device_std_body_open(dtype, pprocs, dname, w, h, xdpi, ydpi)\
  311.     std_device_body_with_macros_(dtype, pprocs, dname, 0,\
  312.       w, h, xdpi, ydpi,\
  313.       open_init_open, dci_black_and_white_, no_margins_)
  314.  
  315. #define std_device_full_body(dtype, pprocs, dname, w, h, xdpi, ydpi, ncomp, depth, mg, mc, dg, dc, xoff, yoff, lm, bm, rm, tm)\
  316.     std_device_part1_(dtype, pprocs, dname, 0, open_init_closed),\
  317.     dci_values(ncomp, depth, mg, mc, dg, dc),\
  318.     std_device_part2_(w, h, xdpi, ydpi),\
  319.     offset_margin_values(xoff, yoff, lm, bm, rm, tm),\
  320.     std_device_part3_()
  321.  
  322. #define std_device_dci_type_body(dtype, pprocs, dname, stype, w, h, xdpi, ydpi, ncomp, depth, mg, mc, dg, dc)\
  323.     std_device_part1_(dtype, pprocs, dname, stype, open_init_closed),\
  324.     dci_values(ncomp, depth, mg, mc, dg, dc),\
  325.     std_device_part2_(w, h, xdpi, ydpi),\
  326.     offset_margin_values(0, 0, 0, 0, 0, 0),\
  327.     std_device_part3_()
  328.  
  329. #define std_device_dci_body(dtype, pprocs, dname, w, h, xdpi, ydpi, ncomp, depth, mg, mc, dg, dc)\
  330.     std_device_dci_type_body(dtype, pprocs, dname, 0,\
  331.       w, h, xdpi, ydpi, ncomp, depth, mg, mc, dg, dc)
  332.  
  333. #define std_device_color_full_body(dtype, pprocs, dname, w, h, xdpi, ydpi, depth, max_value, dither, xoff, yoff, lm, bm, rm, tm)\
  334.     std_device_part1_(dtype, pprocs, dname, 0, open_init_closed),\
  335.     dci_color(depth, max_value, dither),\
  336.     std_device_part2_(w, h, xdpi, ydpi),\
  337.     offset_margin_values(xoff, yoff, lm, bm, rm, tm),\
  338.     std_device_part3_()
  339.  
  340. #define std_device_color_body(dtype, pprocs, dname, w, h, xdpi, ydpi, depth, max_value, dither)\
  341.     std_device_color_full_body(dtype, pprocs, dname,\
  342.       w, h, xdpi, ydpi,\
  343.       depth, max_value, dither,\
  344.       0, 0, 0, 0, 0, 0)
  345.  
  346. #define std_device_color_stype_body(dtype, pprocs, dname, stype, w, h, xdpi, ydpi, depth, max_value, dither)\
  347.     std_device_part1_(dtype, pprocs, dname, stype, open_init_closed),\
  348.     dci_color(depth, max_value, dither),\
  349.     std_device_part2_(w, h, xdpi, ydpi),\
  350.     offset_margin_values(0, 0, 0, 0, 0, 0),\
  351.     std_device_part3_()
  352.  
  353. #define std_device_std_color_full_body(dtype, pprocs, dname, w, h, xdpi, ydpi, depth, xoff, yoff, lm, bm, rm, tm)\
  354.     std_device_part1_(dtype, pprocs, dname, 0, open_init_closed),\
  355.     dci_std_color(depth),\
  356.     std_device_part2_(w, h, xdpi, ydpi),\
  357.     offset_margin_values(xoff, yoff, lm, bm, rm, tm),\
  358.     std_device_part3_()
  359.  
  360. /* ---------------- Device procedures ---------------- */
  361.  
  362. /* Define an opaque type for parameter lists. */
  363. #ifndef gs_param_list_DEFINED
  364. #  define gs_param_list_DEFINED
  365. typedef struct gs_param_list_s gs_param_list;
  366. #endif
  367.  
  368. /*
  369.  * Definition of device procedures.
  370.  * Note that the gx_device * argument is not declared const,
  371.  * because many drivers maintain dynamic state in the device structure.
  372.  * Note also that the structure is defined as a template, so that
  373.  * we can instantiate it with device subclasses.
  374.  * Because C doesn't have real templates, we must do this with macros.
  375.  */
  376.  
  377. /* Define macros for declaring device procedures. */
  378.  
  379. #define dev_t_proc_open_device(proc, dev_t)\
  380.   int proc(P1(dev_t *dev))
  381. #define dev_proc_open_device(proc)\
  382.   dev_t_proc_open_device(proc, gx_device)
  383.  
  384. #define dev_t_proc_get_initial_matrix(proc, dev_t)\
  385.   void proc(P2(dev_t *dev, gs_matrix *pmat))
  386. #define dev_proc_get_initial_matrix(proc)\
  387.   dev_t_proc_get_initial_matrix(proc, gx_device)
  388.  
  389. #define dev_t_proc_sync_output(proc, dev_t)\
  390.   int proc(P1(dev_t *dev))
  391. #define dev_proc_sync_output(proc)\
  392.   dev_t_proc_sync_output(proc, gx_device)
  393.  
  394. #define dev_t_proc_output_page(proc, dev_t)\
  395.   int proc(P3(dev_t *dev, int num_copies, int flush))
  396. #define dev_proc_output_page(proc)\
  397.   dev_t_proc_output_page(proc, gx_device)
  398.  
  399. #define dev_t_proc_close_device(proc, dev_t)\
  400.   int proc(P1(dev_t *dev))
  401. #define dev_proc_close_device(proc)\
  402.   dev_t_proc_close_device(proc, gx_device)
  403.  
  404. #define dev_t_proc_map_rgb_color(proc, dev_t)\
  405.   gx_color_index proc(P4(dev_t *dev,\
  406.     gx_color_value red, gx_color_value green, gx_color_value blue))
  407. #define dev_proc_map_rgb_color(proc)\
  408.   dev_t_proc_map_rgb_color(proc, gx_device)
  409.  
  410. #define dev_t_proc_map_color_rgb(proc, dev_t)\
  411.   int proc(P3(dev_t *dev,\
  412.     gx_color_index color, gx_color_value rgb[3]))
  413. #define dev_proc_map_color_rgb(proc)\
  414.   dev_t_proc_map_color_rgb(proc, gx_device)
  415.  
  416. #define dev_t_proc_fill_rectangle(proc, dev_t)\
  417.   int proc(P6(dev_t *dev,\
  418.     int x, int y, int width, int height, gx_color_index color))
  419. #define dev_proc_fill_rectangle(proc)\
  420.   dev_t_proc_fill_rectangle(proc, gx_device)
  421.  
  422. #define dev_t_proc_tile_rectangle(proc, dev_t)\
  423.   int proc(P10(dev_t *dev,\
  424.     const gx_tile_bitmap *tile, int x, int y, int width, int height,\
  425.     gx_color_index color0, gx_color_index color1,\
  426.     int phase_x, int phase_y))
  427. #define dev_proc_tile_rectangle(proc)\
  428.   dev_t_proc_tile_rectangle(proc, gx_device)
  429.  
  430. #define dev_t_proc_copy_mono(proc, dev_t)\
  431.   int proc(P11(dev_t *dev,\
  432.     const byte *data, int data_x, int raster, gx_bitmap_id id,\
  433.     int x, int y, int width, int height,\
  434.     gx_color_index color0, gx_color_index color1))
  435. #define dev_proc_copy_mono(proc)\
  436.   dev_t_proc_copy_mono(proc, gx_device)
  437.  
  438. #define dev_t_proc_copy_color(proc, dev_t)\
  439.   int proc(P9(dev_t *dev,\
  440.     const byte *data, int data_x, int raster, gx_bitmap_id id,\
  441.     int x, int y, int width, int height))
  442. #define dev_proc_copy_color(proc)\
  443.   dev_t_proc_copy_color(proc, gx_device)
  444.  
  445.         /* OBSOLETED in release 3.66 */
  446.  
  447. #define dev_t_proc_draw_line(proc, dev_t)\
  448.   int proc(P6(dev_t *dev,\
  449.     int x0, int y0, int x1, int y1, gx_color_index color))
  450. #define dev_proc_draw_line(proc)\
  451.   dev_t_proc_draw_line(proc, gx_device)
  452.  
  453.         /* Added in release 2.4 */
  454.  
  455. #define dev_t_proc_get_bits(proc, dev_t)\
  456.   int proc(P4(dev_t *dev,\
  457.     int y, byte *data, byte **actual_data))
  458. #define dev_proc_get_bits(proc)\
  459.   dev_t_proc_get_bits(proc, gx_device)
  460.  
  461.         /* Added in release 2.4, changed in 2.8, */
  462.         /* renamed in 2.9.6 */
  463.  
  464. #define dev_t_proc_get_params(proc, dev_t)\
  465.   int proc(P2(dev_t *dev, gs_param_list *plist))
  466. #define dev_proc_get_params(proc)\
  467.   dev_t_proc_get_params(proc, gx_device)
  468.  
  469. #define dev_t_proc_put_params(proc, dev_t)\
  470.   int proc(P2(dev_t *dev, gs_param_list *plist))
  471. #define dev_proc_put_params(proc)\
  472.   dev_t_proc_put_params(proc, gx_device)
  473.  
  474.         /* Added in release 2.6 */
  475.  
  476. #define dev_t_proc_map_cmyk_color(proc, dev_t)\
  477.   gx_color_index proc(P5(dev_t *dev,\
  478.     gx_color_value cyan, gx_color_value magenta, gx_color_value yellow,\
  479.     gx_color_value black))
  480. #define dev_proc_map_cmyk_color(proc)\
  481.   dev_t_proc_map_cmyk_color(proc, gx_device)
  482.  
  483. #define dev_t_proc_get_xfont_procs(proc, dev_t)\
  484.   gx_xfont_procs *proc(P1(dev_t *dev))
  485. #define dev_proc_get_xfont_procs(proc)\
  486.   dev_t_proc_get_xfont_procs(proc, gx_device)
  487.  
  488.         /* Added in release 2.6.1 */
  489.  
  490. #define dev_t_proc_get_xfont_device(proc, dev_t)\
  491.   gx_device *proc(P1(dev_t *dev))
  492. #define dev_proc_get_xfont_device(proc)\
  493.   dev_t_proc_get_xfont_device(proc, gx_device)
  494.  
  495.         /* Added in release 2.7.1 */
  496.  
  497. #define dev_t_proc_map_rgb_alpha_color(proc, dev_t)\
  498.   gx_color_index proc(P5(dev_t *dev,\
  499.     gx_color_value red, gx_color_value green, gx_color_value blue,\
  500.     gx_color_value alpha))
  501. #define dev_proc_map_rgb_alpha_color(proc)\
  502.   dev_t_proc_map_rgb_alpha_color(proc, gx_device)
  503.  
  504.         /* Added in release 2.8.1 */
  505.  
  506. #define dev_t_proc_get_page_device(proc, dev_t)\
  507.   gx_device *proc(P1(dev_t *dev))
  508. #define dev_proc_get_page_device(proc)\
  509.   dev_t_proc_get_page_device(proc, gx_device)
  510.  
  511.         /* Added in release 3.20 */
  512.  
  513. #define dev_t_proc_get_alpha_bits(proc, dev_t)\
  514.   int proc(P2(dev_t *dev, graphics_object_type type))
  515. #define dev_proc_get_alpha_bits(proc)\
  516.   dev_t_proc_get_alpha_bits(proc, gx_device)
  517.  
  518. #define dev_t_proc_copy_alpha(proc, dev_t)\
  519.   int proc(P11(dev_t *dev, const byte *data, int data_x,\
  520.     int raster, gx_bitmap_id id, int x, int y, int width, int height,\
  521.     gx_color_index color, int depth))
  522. #define dev_proc_copy_alpha(proc)\
  523.   dev_t_proc_copy_alpha(proc, gx_device)
  524.  
  525.         /* Added in release 3.38 */
  526.  
  527. #define dev_t_proc_get_band(proc, dev_t)\
  528.   int proc(P3(dev_t *dev, int y, int *band_start))
  529. #define dev_proc_get_band(proc)\
  530.   dev_t_proc_get_band(proc, gx_device)
  531.  
  532.         /* Added in release 3.44 */
  533.  
  534. #define dev_t_proc_copy_rop(proc, dev_t)\
  535.   int proc(P15(dev_t *dev,\
  536.     const byte *sdata, int sourcex, uint sraster, gx_bitmap_id id,\
  537.     const gx_color_index *scolors,\
  538.     const gx_tile_bitmap *texture, const gx_color_index *tcolors,\
  539.     int x, int y, int width, int height,\
  540.     int phase_x, int phase_y, gs_logical_operation_t lop))
  541. #define dev_proc_copy_rop(proc)\
  542.   dev_t_proc_copy_rop(proc, gx_device)
  543.  
  544.         /* Added in release 3.60, changed in release 3.68. */
  545.  
  546. #define dev_t_proc_fill_path(proc, dev_t)\
  547.   int proc(P6(dev_t *dev,\
  548.     const gs_imager_state *pis, gx_path *ppath,\
  549.     const gx_fill_params *params,\
  550.     const gx_drawing_color *pdcolor, const gx_clip_path *pcpath))
  551. #define dev_proc_fill_path(proc)\
  552.   dev_t_proc_fill_path(proc, gx_device)
  553.  
  554. #define dev_t_proc_stroke_path(proc, dev_t)\
  555.   int proc(P6(dev_t *dev,\
  556.     const gs_imager_state *pis, gx_path *ppath,\
  557.     const gx_stroke_params *params,\
  558.     const gx_drawing_color *pdcolor, const gx_clip_path *pcpath))
  559. #define dev_proc_stroke_path(proc)\
  560.   dev_t_proc_stroke_path(proc, gx_device)
  561.  
  562.         /* Added in release 3.60 */
  563.  
  564. #define dev_t_proc_fill_mask(proc, dev_t)\
  565.   int proc(P13(dev_t *dev,\
  566.     const byte *data, int data_x, int raster, gx_bitmap_id id,\
  567.     int x, int y, int width, int height,\
  568.     const gx_drawing_color *pdcolor, int depth,\
  569.     gs_logical_operation_t lop, const gx_clip_path *pcpath))
  570. #define dev_proc_fill_mask(proc)\
  571.   dev_t_proc_fill_mask(proc, gx_device)
  572.  
  573.         /* Added in release 3.66, changed in 3.69 */
  574.  
  575. #define dev_t_proc_fill_trapezoid(proc, dev_t)\
  576.   int proc(P8(dev_t *dev,\
  577.     const gs_fixed_edge *left, const gs_fixed_edge *right,\
  578.     fixed ybot, fixed ytop, bool swap_axes,\
  579.     const gx_drawing_color *pdcolor, gs_logical_operation_t lop))
  580. #define dev_proc_fill_trapezoid(proc)\
  581.   dev_t_proc_fill_trapezoid(proc, gx_device)
  582.  
  583. #define dev_t_proc_fill_parallelogram(proc, dev_t)\
  584.   int proc(P9(dev_t *dev,\
  585.     fixed px, fixed py, fixed ax, fixed ay, fixed bx, fixed by,\
  586.     const gx_drawing_color *pdcolor, gs_logical_operation_t lop))
  587. #define dev_proc_fill_parallelogram(proc)\
  588.   dev_t_proc_fill_parallelogram(proc, gx_device)
  589.  
  590. #define dev_t_proc_fill_triangle(proc, dev_t)\
  591.   int proc(P9(dev_t *dev,\
  592.     fixed px, fixed py, fixed ax, fixed ay, fixed bx, fixed by,\
  593.     const gx_drawing_color *pdcolor, gs_logical_operation_t lop))
  594. #define dev_proc_fill_triangle(proc)\
  595.   dev_t_proc_fill_triangle(proc, gx_device)
  596.  
  597. #define dev_t_proc_draw_thin_line(proc, dev_t)\
  598.   int proc(P7(dev_t *dev,\
  599.     fixed fx0, fixed fy0, fixed fx1, fixed fy1,\
  600.     const gx_drawing_color *pdcolor, gs_logical_operation_t lop))
  601. #define dev_proc_draw_thin_line(proc)\
  602.   dev_t_proc_draw_thin_line(proc, gx_device)
  603.  
  604.         /* Added in release 3.66 (as stubs); */
  605.         /* changed in 3.68; */
  606.         /* begin_image and image_data changed in 4.30 */
  607.  
  608. #define dev_t_proc_begin_image(proc, dev_t)\
  609.   int proc(P9(dev_t *dev,\
  610.     const gs_imager_state *pis, const gs_image_t *pim,\
  611.     gs_image_format_t format, const gs_int_rect *prect,\
  612.     const gx_drawing_color *pdcolor, const gx_clip_path *pcpath,\
  613.     gs_memory_t *memory, void **pinfo))
  614. #define dev_proc_begin_image(proc)\
  615.   dev_t_proc_begin_image(proc, gx_device)
  616.  
  617. #define dev_t_proc_image_data(proc, dev_t)\
  618.   int proc(P6(dev_t *dev,\
  619.     void *info, const byte **planes, int data_x, uint raster, int height))
  620. #define dev_proc_image_data(proc)\
  621.   dev_t_proc_image_data(proc, gx_device)
  622.  
  623. #define dev_t_proc_end_image(proc, dev_t)\
  624.   int proc(P3(dev_t *dev,\
  625.     void *info, bool draw_last))
  626. #define dev_proc_end_image(proc)\
  627.   dev_t_proc_end_image(proc, gx_device)
  628.  
  629.         /* Added in release 3.68 */
  630.  
  631. #define dev_t_proc_strip_tile_rectangle(proc, dev_t)\
  632.   int proc(P10(dev_t *dev,\
  633.     const gx_strip_bitmap *tiles, int x, int y, int width, int height,\
  634.     gx_color_index color0, gx_color_index color1,\
  635.     int phase_x, int phase_y))
  636. #define dev_proc_strip_tile_rectangle(proc)\
  637.   dev_t_proc_strip_tile_rectangle(proc, gx_device)
  638.  
  639. #define dev_t_proc_strip_copy_rop(proc, dev_t)\
  640.   int proc(P15(dev_t *dev,\
  641.     const byte *sdata, int sourcex, uint sraster, gx_bitmap_id id,\
  642.     const gx_color_index *scolors,\
  643.     const gx_strip_bitmap *textures, const gx_color_index *tcolors,\
  644.     int x, int y, int width, int height,\
  645.     int phase_x, int phase_y, gs_logical_operation_t lop))
  646. #define dev_proc_strip_copy_rop(proc)\
  647.   dev_t_proc_strip_copy_rop(proc, gx_device)
  648.  
  649.         /* Added in release 4.20 */
  650.  
  651. #define dev_t_proc_get_clipping_box(proc, dev_t)\
  652.   void proc(P2(dev_t *dev, gs_fixed_rect *pbox))
  653. #define dev_proc_get_clipping_box(proc)\
  654.   dev_t_proc_get_clipping_box(proc, gx_device)
  655.  
  656. /* Define the device procedure vector template proper. */
  657.  
  658. #define gx_device_proc_struct(dev_t)\
  659. {    dev_t_proc_open_device((*open_device), dev_t);\
  660.     dev_t_proc_get_initial_matrix((*get_initial_matrix), dev_t);\
  661.     dev_t_proc_sync_output((*sync_output), dev_t);\
  662.     dev_t_proc_output_page((*output_page), dev_t);\
  663.     dev_t_proc_close_device((*close_device), dev_t);\
  664.     dev_t_proc_map_rgb_color((*map_rgb_color), dev_t);\
  665.     dev_t_proc_map_color_rgb((*map_color_rgb), dev_t);\
  666.     dev_t_proc_fill_rectangle((*fill_rectangle), dev_t);\
  667.     dev_t_proc_tile_rectangle((*tile_rectangle), dev_t);\
  668.     dev_t_proc_copy_mono((*copy_mono), dev_t);\
  669.     dev_t_proc_copy_color((*copy_color), dev_t);\
  670.     dev_t_proc_draw_line((*draw_line), dev_t);\
  671.     dev_t_proc_get_bits((*get_bits), dev_t);\
  672.     dev_t_proc_get_params((*get_params), dev_t);\
  673.     dev_t_proc_put_params((*put_params), dev_t);\
  674.     dev_t_proc_map_cmyk_color((*map_cmyk_color), dev_t);\
  675.     dev_t_proc_get_xfont_procs((*get_xfont_procs), dev_t);\
  676.     dev_t_proc_get_xfont_device((*get_xfont_device), dev_t);\
  677.     dev_t_proc_map_rgb_alpha_color((*map_rgb_alpha_color), dev_t);\
  678.     dev_t_proc_get_page_device((*get_page_device), dev_t);\
  679.     dev_t_proc_get_alpha_bits((*get_alpha_bits), dev_t);\
  680.     dev_t_proc_copy_alpha((*copy_alpha), dev_t);\
  681.     dev_t_proc_get_band((*get_band), dev_t);\
  682.     dev_t_proc_copy_rop((*copy_rop), dev_t);\
  683.     dev_t_proc_fill_path((*fill_path), dev_t);\
  684.     dev_t_proc_stroke_path((*stroke_path), dev_t);\
  685.     dev_t_proc_fill_mask((*fill_mask), dev_t);\
  686.     dev_t_proc_fill_trapezoid((*fill_trapezoid), dev_t);\
  687.     dev_t_proc_fill_parallelogram((*fill_parallelogram), dev_t);\
  688.     dev_t_proc_fill_triangle((*fill_triangle), dev_t);\
  689.     dev_t_proc_draw_thin_line((*draw_thin_line), dev_t);\
  690.     dev_t_proc_begin_image((*begin_image), dev_t);\
  691.     dev_t_proc_image_data((*image_data), dev_t);\
  692.     dev_t_proc_end_image((*end_image), dev_t);\
  693.     dev_t_proc_strip_tile_rectangle((*strip_tile_rectangle), dev_t);\
  694.     dev_t_proc_strip_copy_rop((*strip_copy_rop), dev_t);\
  695.     dev_t_proc_get_clipping_box((*get_clipping_box), dev_t);\
  696. }
  697.  
  698. /* A generic device procedure record. */
  699. struct gx_device_procs_s gx_device_proc_struct(gx_device);
  700.  
  701. /*
  702.  * Define a procedure for setting up a memory device for buffering output
  703.  * for a given device.  This is only used by band devices, but we define it
  704.  * here for convenience.  The default implementation just calls
  705.  * gs_make_mem_device.  Possibly this should be a generic device
  706.  * procedure....
  707.  */
  708. #ifndef gx_device_memory_DEFINED
  709. #  define gx_device_memory_DEFINED
  710. typedef struct gx_device_memory_s gx_device_memory;
  711. #endif
  712. #define dev_proc_make_buffer_device(proc)\
  713.   int proc(P4(gx_device_memory *, gx_device *, gs_memory_t *, bool))
  714. dev_proc_make_buffer_device(gx_default_make_buffer_device);
  715.  
  716. /*
  717.  * Define unaligned analogues of the copy_xxx procedures.
  718.  * These are slower than the standard procedures, which require
  719.  * aligned bitmaps, and also are not portable to non-byte-addressed machines.
  720.  *
  721.  * We allow both unaligned data and unaligned scan line widths;
  722.  * however, we do require that both of these be aligned modulo the largest
  723.  * power of 2 bytes that divides the data depth, i.e.:
  724.  *    depth    alignment
  725.  *    <= 8    1
  726.  *    16    2
  727.  *    24    1
  728.  *    32    4
  729.  */
  730. dev_proc_copy_mono(gx_copy_mono_unaligned);
  731. dev_proc_copy_color(gx_copy_color_unaligned);
  732. dev_proc_copy_alpha(gx_copy_alpha_unaligned);
  733.  
  734. /* A generic device */
  735. struct gx_device_s {
  736.     gx_device_common;
  737. };
  738. extern_st(st_device);
  739. struct_proc_finalize(gx_device_finalize);    /* public for subclasses */
  740. /* We use vacuous enum/reloc procedures, rather than 0, so that */
  741. /* gx_device can have subclasses. */
  742. #define public_st_device()    /* in gsdevice.c */\
  743.   gs_public_st_complex_only(st_device, gx_device, "gx_device",\
  744.     0, gs_no_struct_enum_ptrs, gs_no_struct_reloc_ptrs, gx_device_finalize)
  745. #define st_device_max_ptrs 0
  746.  
  747. /* Enumerate or relocate a pointer to a device. */
  748. /* These take the containing space into account properly. */
  749. gx_device *gx_device_enum_ptr(P1(gx_device *));
  750. gx_device *gx_device_reloc_ptr(P2(gx_device *, gc_state_t *));
  751.  
  752. /* Define typedefs for some of the device procedures, because */
  753. /* ansi2knr can't handle dev_proc_xxx((*xxx)) in a formal argument list. */
  754. typedef dev_proc_map_rgb_color((*dev_proc_map_rgb_color_t));
  755. typedef dev_proc_map_color_rgb((*dev_proc_map_color_rgb_t));
  756.  
  757. /* A device that forwards non-display operations to another device */
  758. /* called the "target".  This is used for clipping, banding, image, */
  759. /* and null devices. */
  760. #define gx_device_forward_common\
  761.     gx_device_common;\
  762.     gx_device *target
  763. /* A generic forwarding device. */
  764. typedef struct gx_device_forward_s {
  765.     gx_device_forward_common;
  766. } gx_device_forward;
  767. extern_st(st_device_forward);
  768. #define public_st_device_forward()    /* in gsdevice.c */\
  769.   gs_public_st_complex_only(st_device_forward, gx_device_forward,\
  770.     "gx_device_forward", 0, device_forward_enum_ptrs,\
  771.     device_forward_reloc_ptrs, gx_device_finalize)
  772. #define st_device_forward_max_ptrs (st_device_max_ptrs + 1)
  773.  
  774. /* A null device.  This is used to temporarily disable output. */
  775. #ifndef gx_device_null_DEFINED
  776. #  define gx_device_null_DEFINED
  777. typedef struct gx_device_null_s gx_device_null;
  778. #endif
  779. struct gx_device_null_s {
  780.     gx_device_forward_common;
  781. };
  782. extern gx_device_null far_data gs_null_device;    /* (should be const) */
  783. extern_st(st_device_null);
  784. #define public_st_device_null()    /* in gsdevice.c */\
  785.   gs_public_st_complex_only(st_device_null, gx_device_null,\
  786.     "gx_device_null", 0, device_forward_enum_ptrs,\
  787.     device_forward_reloc_ptrs, gx_device_finalize)
  788. #define st_device_null_max_ptrs st_device_forward_max_ptrs
  789. /* Make a null device. */
  790. /* The gs_memory_t argument is 0 if the device is temporary and local, */
  791. /* or the allocator that was used to allocate it if it is a real object. */
  792. void    gs_make_null_device(P2(gx_device_null *, gs_memory_t *));
  793.  
  794. /* Calculate the raster (number of bytes in a scan line), */
  795. /* with byte or word padding. */
  796. uint    gx_device_raster(P2(const gx_device *dev, bool pad_to_word));
  797.  
  798. /* Adjust the resolution for devices that only have a fixed set of */
  799. /* geometries, so that the apparent size in inches remains constant. */
  800. /* If fit=1, the resolution is adjusted so that the entire image fits; */
  801. /* if fit=0, one dimension fits, but the other one is clipped. */
  802. int    gx_device_adjust_resolution(P4(gx_device *dev, int actual_width, int actual_height, int fit));
  803.  
  804. /* Set the HWMargins to values defined in inches. */
  805. /* If move_origin is true, also reset the Margins. */
  806. void    gx_device_set_margins(P3(gx_device *dev, const float *margins /*[4]*/,
  807.   bool move_origin));
  808.  
  809. /* Set the width and height (in pixels), updating MediaSize. */
  810. void gx_device_set_width_height(P3(gx_device *dev, int width, int height));
  811. /* Set the resolution (in pixels per inch), updating width and height. */
  812. void gx_device_set_resolution(P3(gx_device *dev, floatp x_dpi, floatp y_dpi));
  813. /* Set the MediaSize (in 1/72" units), updating width and height. */
  814. void gx_device_set_media_size(P3(gx_device *dev, floatp media_width, floatp media_height));
  815. /****** BACKWARD COMPATIBILITY ******/
  816. #define gx_device_set_page_size(dev, w, h)\
  817.   gx_device_set_media_size(dev, w, h)
  818.  
  819. /*
  820.  * Macros to help the drawing procedures clip coordinates to
  821.  * fit into the drawing region.  Note that these may modify
  822.  * x, y, w, h, data, data_x, and id.
  823.  */
  824.  
  825. /* Macros for fill_rectangle and [strip_]tile_rectangle. */
  826. #define fit_fill_xyw(dev, x, y, w, h)\
  827.     if ( (x | y) < 0 )\
  828.     {    if ( x < 0 ) w += x, x = 0;\
  829.         if ( y < 0 ) h += y, y = 0;\
  830.     }\
  831.     if ( x > dev->width - w ) w = dev->width - x
  832. #define fit_fill_y(dev, y, h)\
  833.     if ( y < 0 ) h += y, y = 0
  834. #define fit_fill_h(dev, y, h)\
  835.     if ( y > dev->height - h ) h = dev->height - y
  836. #define fit_fill_yh(dev, y, h)\
  837.     fit_fill_y(dev, y, h);\
  838.     fit_fill_h(dev, y, h)
  839. #define fit_fill_xywh(dev, x, y, w, h)\
  840.     fit_fill_xyw(dev, x, y, w, h);\
  841.     fit_fill_h(dev, y, h)
  842. #define fit_fill(dev, x, y, w, h)\
  843.     fit_fill_xywh(dev, x, y, w, h);\
  844.     if ( w <= 0 || h <= 0 ) return 0
  845.  
  846. /* Macro for copy_mono and copy_color. */
  847. #define fit_copy_xw(dev, data, data_x, raster, id, x, y, w, h)\
  848.     if ( (x | y) < 0 )\
  849.     {    if ( x < 0 ) w += x, data_x -= x, x = 0;\
  850.         if ( y < 0 ) h += y, data -= y * raster, id = gx_no_bitmap_id, y = 0;\
  851.     }\
  852.     if ( x > dev->width - w ) w = dev->width - x
  853. #define fit_copy_xwh(dev, data, data_x, raster, id, x, y, w, h)\
  854.     fit_copy_xw(dev, data, data_x, raster, id, x, y, w, h);\
  855.     if ( w <= 0 || h <= 0 ) return 0
  856. #define fit_copy(dev, data, data_x, raster, id, x, y, w, h)\
  857.     fit_copy_xw(dev, data, data_x, raster, id, x, y, w, h);\
  858.     if ( y > dev->height - h ) h = dev->height - y;\
  859.     if ( w <= 0 || h <= 0 ) return 0
  860.  
  861. /* Default implementations of optional procedures. */
  862. /* Note that the default map_xxx_color routines assume white_on_black. */
  863. dev_proc_open_device(gx_default_open_device);
  864. dev_proc_get_initial_matrix(gx_default_get_initial_matrix);
  865. dev_proc_get_initial_matrix(gx_upright_get_initial_matrix);
  866. dev_proc_sync_output(gx_default_sync_output);
  867. dev_proc_output_page(gx_default_output_page);
  868. dev_proc_close_device(gx_default_close_device);
  869. dev_proc_map_rgb_color(gx_default_w_b_map_rgb_color);
  870. dev_proc_map_color_rgb(gx_default_w_b_map_color_rgb);
  871. #define gx_default_map_rgb_color gx_default_w_b_map_rgb_color
  872. #define gx_default_map_color_rgb gx_default_w_b_map_color_rgb
  873. dev_proc_tile_rectangle(gx_default_tile_rectangle);
  874. dev_proc_copy_mono(gx_default_copy_mono);
  875. dev_proc_copy_color(gx_default_copy_color);
  876. dev_proc_draw_line(gx_default_draw_line);
  877. dev_proc_get_bits(gx_default_get_bits);
  878. dev_proc_get_params(gx_default_get_params);
  879. dev_proc_put_params(gx_default_put_params);
  880. dev_proc_map_cmyk_color(gx_default_map_cmyk_color);
  881. dev_proc_get_xfont_procs(gx_default_get_xfont_procs);
  882. dev_proc_get_xfont_device(gx_default_get_xfont_device);
  883. dev_proc_map_rgb_alpha_color(gx_default_map_rgb_alpha_color);
  884. dev_proc_get_page_device(gx_default_get_page_device);    /* returns NULL */
  885. dev_proc_get_page_device(gx_page_device_get_page_device);  /* returns dev */
  886. dev_proc_get_alpha_bits(gx_default_get_alpha_bits);
  887. dev_proc_copy_alpha(gx_no_copy_alpha);        /* gives error */
  888. dev_proc_copy_alpha(gx_default_copy_alpha);
  889. dev_proc_get_band(gx_default_get_band);
  890. dev_proc_copy_rop(gx_no_copy_rop);        /* gives error */
  891. extern dev_proc_copy_rop((*gx_default_copy_rop_proc));
  892. dev_proc_copy_rop(gx_default_copy_rop);        /* calls ...proc */
  893. dev_proc_fill_path(gx_default_fill_path);
  894. dev_proc_stroke_path(gx_default_stroke_path);
  895. dev_proc_fill_mask(gx_default_fill_mask);
  896. dev_proc_fill_trapezoid(gx_default_fill_trapezoid);
  897. dev_proc_fill_parallelogram(gx_default_fill_parallelogram);
  898. dev_proc_fill_triangle(gx_default_fill_triangle);
  899. dev_proc_draw_thin_line(gx_default_draw_thin_line);
  900. dev_proc_begin_image(gx_default_begin_image);
  901. dev_proc_image_data(gx_default_image_data);
  902. dev_proc_end_image(gx_default_end_image);
  903. dev_proc_strip_tile_rectangle(gx_default_strip_tile_rectangle);
  904. dev_proc_strip_copy_rop(gx_no_strip_copy_rop);        /* gives error */
  905. extern dev_proc_strip_copy_rop((*gx_default_strip_copy_rop_proc));
  906. dev_proc_strip_copy_rop(gx_default_strip_copy_rop);    /* calls ...proc */
  907. dev_proc_get_clipping_box(gx_default_get_clipping_box);
  908. dev_proc_get_clipping_box(gx_get_largest_clipping_box);
  909.  
  910. /* Color mapping routines for black-on-white, gray scale, true RGB, */
  911. /* and true CMYK color. */
  912. dev_proc_map_rgb_color(gx_default_b_w_map_rgb_color);
  913. dev_proc_map_color_rgb(gx_default_b_w_map_color_rgb);
  914. dev_proc_map_rgb_color(gx_default_gray_map_rgb_color);
  915. dev_proc_map_color_rgb(gx_default_gray_map_color_rgb);
  916. dev_proc_map_rgb_color(gx_default_rgb_map_rgb_color);
  917. dev_proc_map_color_rgb(gx_default_rgb_map_color_rgb);
  918. dev_proc_map_cmyk_color(gx_default_cmyk_map_cmyk_color);
  919.  
  920. /* Default implementations for forwarding devices */
  921. dev_proc_get_initial_matrix(gx_forward_get_initial_matrix);
  922. dev_proc_sync_output(gx_forward_sync_output);
  923. dev_proc_output_page(gx_forward_output_page);
  924. dev_proc_map_rgb_color(gx_forward_map_rgb_color);
  925. dev_proc_map_color_rgb(gx_forward_map_color_rgb);
  926. dev_proc_tile_rectangle(gx_forward_tile_rectangle);
  927. dev_proc_get_bits(gx_forward_get_bits);
  928. dev_proc_get_params(gx_forward_get_params);
  929. dev_proc_put_params(gx_forward_put_params);
  930. dev_proc_map_cmyk_color(gx_forward_map_cmyk_color);
  931. dev_proc_get_xfont_procs(gx_forward_get_xfont_procs);
  932. dev_proc_get_xfont_device(gx_forward_get_xfont_device);
  933. dev_proc_map_rgb_alpha_color(gx_forward_map_rgb_alpha_color);
  934. dev_proc_get_page_device(gx_forward_get_page_device);
  935. dev_proc_get_alpha_bits(gx_forward_get_alpha_bits);
  936. dev_proc_get_band(gx_forward_get_band);
  937. extern dev_proc_copy_rop((*gx_forward_copy_rop_proc));
  938. dev_proc_fill_path(gx_forward_fill_path);
  939. dev_proc_stroke_path(gx_forward_stroke_path);
  940. dev_proc_fill_mask(gx_forward_fill_mask);
  941. dev_proc_fill_trapezoid(gx_forward_fill_trapezoid);
  942. dev_proc_fill_parallelogram(gx_forward_fill_parallelogram);
  943. dev_proc_fill_triangle(gx_forward_fill_triangle);
  944. dev_proc_draw_thin_line(gx_forward_draw_thin_line);
  945. dev_proc_begin_image(gx_forward_begin_image);
  946. dev_proc_image_data(gx_forward_image_data);
  947. dev_proc_end_image(gx_forward_end_image);
  948. dev_proc_strip_tile_rectangle(gx_forward_strip_tile_rectangle);
  949. extern dev_proc_strip_copy_rop((*gx_forward_strip_copy_rop_proc));
  950. dev_proc_get_clipping_box(gx_forward_get_clipping_box);
  951.  
  952. /* Convert the device procedures to the proper form (see above). */
  953. void    gx_device_set_procs(P1(gx_device *));
  954.  
  955. /* Fill in defaulted procedures in a device procedure record. */
  956. void    gx_device_fill_in_procs(P1(gx_device *));
  957. void    gx_device_forward_fill_in_procs(P1(gx_device_forward *));
  958.  
  959. /* Forward the color mapping procedures from a device to its target. */
  960. void    gx_device_forward_color_procs(P1(gx_device_forward *));
  961.  
  962. /* Temporarily install a null device, or a special device such as */
  963. /* a clipping device. */
  964. void gx_device_no_output(P1(gs_state *));
  965. void gx_set_device_only(P2(gs_state *, gx_device *));
  966.  
  967. /* Open the output file for a device. */
  968. int gx_device_open_output_file(P5(const gx_device *dev, const char *fname,
  969.                   bool binary, bool positionable,
  970.                   FILE **pfile));
  971.  
  972. /* Close a device. */
  973. int gs_closedevice(P1(gx_device *));
  974.  
  975. /* ------ Device types ------ */
  976.  
  977. #define dev_type_proc_initialize(proc)\
  978.   int proc(P1(gx_device *))
  979.  
  980. typedef struct gx_device_type_s {
  981.     gs_memory_type_ptr_t stype;
  982.     dev_type_proc_initialize((*initialize));
  983. } gx_device_type;
  984.  
  985. #define device_type(dtname, stype, initproc)\
  986. private dev_type_proc_initialize(initproc);\
  987. const gx_device_type dtname = { &stype, initproc }
  988.  
  989. dev_type_proc_initialize(gdev_initialize);
  990.  
  991. #endif                    /* gxdevice_INCLUDED */
  992.